﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace nunit_demo
{
    class Program
    {
        static void Main(string[] args)
        {
            object lock1 = new object();

            Thread t1 = new Thread(() =>
            {
                while (true)
                {
                    lock (lock1)
                    {
                        // 将光标移动到指定坐标下
                        Console.SetCursorPosition(0, 0);
                        // 设置背景色
                        Console.ForegroundColor = ConsoleColor.Red;
                        // 设置图形
                        Console.Write("●");
                    }
                }
            });

            Thread t2 = new Thread(() =>
            {
                while (true)
                {
                    lock (lock1)
                    {
                        Console.SetCursorPosition(10, 10);
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.Write("■");
                    }    
                }
            });

            t1.IsBackground = false;
            t2.IsBackground = false;

            t1.Start();
            t2.Start();
        }
    }

}
